<?php 
/**
 * 类型控制器
 */
class TypeController extends VerifyController{
	private $model;
	public function __init(){
	    $this->model = K('Type');
	}
	/**
	 * 首页
	 */
	public function index(){
		$data = $this->model->check();
		$this->assign("data",$data);
	    $this->display();
	}
	/**
	 * 添加类型
	 */
	public function add(){
		if(IS_POST){
			if(!$this->model->addData()){
				$this->error($this->model->error);
			}
			$this->success("添加成功");
		}
	    $this->display();
	}
	/**
	 * 删除类型
	 */
	 public function del(){
		if(!$this->model->delData(Q('get.tid'))){
				$this->error($this->model->error);
			}
		$this->success("删除成功");
	 }
	 /**
	  * 编辑类型
	  */
	  public function edit(){
	  	$tid = Q("get.tid");
	  	  if(IS_POST){
	  	  	  if(!$this->model->upData($tid)){
	  	  	  	$this->error($this->model->error);
	  	  	  }
			  $this->success("更新成功",U("index"));
	  	  }
	  	  
	      $data = $this->model->where("tid=$tid")->select();
		  $this->assign("data",$data);
	      $this->display();
	  }

}
